use dataset_representation, clear

encode official_g, gen(x)

gen b = .
gen se = .

forvalues i = 1(1)4 {
	bs, reps(1000): reg cong if x == `i', cl(district_official)
 	replace b = _b[_cons] if x == `i' 
	replace se = _se[_cons] if x == `i'
}

collapse b se, by(x)

gen ub = b + 1.96*se
gen lb = b - 1.96*se

#delimit;

gr tw
	(sc b x, col(black))
	(rspike ub lb x, col(black))
	,
		legend(off)
		yline(0.5, lpat(dash))
		plotregion(style(none))
		ylab(0(0.25)1, angle(horiz))
		xtitle("")
		ytitle("Proportion congruent positions")
		xsize(3) ysize(2)
		xlab(
			1 "DA's"
			2 "Local officials"
			3 "State legislators"
			4 "US House members"
		)
		xscale(range(0.75 4.25))
		;

#delimit cr

gr export "_output/figure 4.pdf", replace
